package com.studychen.appfxcp;

import javafx.application.Application;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@SpringBootApplication
@EnableTransactionManagement
@MapperScan(basePackages = "com.studychen.appfxcp.commom.mapper")
public class AppfxCpApplication implements CommandLineRunner{

    private final static Logger log = LoggerFactory.getLogger(AppfxCpApplication.class);

    public static void main(String[] args) {
        SpringApplication.run(AppfxCpApplication.class, args);
        String threadName = Thread.currentThread().getName();
        log.info("lombok is success!\t{}", threadName);
    }

     // 实现在应用初始化后，去执行一段代码块逻辑，这段初始化代码在整个应用生命周期内只会执行一次。
    @Override
    public void run(String... args) throws Exception {
        System.out.println("开启javafx线程");
        new Thread(() -> {
            Application.launch(AppApplication.class, args);
            log.info("spring run thread name: {}", Thread.currentThread().getName());
        }).start();
        log.info("成功启动javafx线程");
    }
}
